<div class="bk-panel bk-demo">
    <div class="bk-panel-body p0">
        <table id="application" class="bk-table table-bordered">
            <thead>
                <tr>
                    <th>所属组织</th>
                    <th>申报奖项</th>
                    <th>奖项状态</th>
                    <th>申报⼈/团队</th>
                    <th>申报状态</th>
                    <th>申报时间</th>
                    <th>操作</th>
                </tr>
            </thead>
        </table>
    </div>
</div>
{% block extra_block %}
<script>
    //表格(DataTables)
    var language = {
        search: "{% trans '搜索：' %}",
        lengthMenu: "{% trans '每⻚显示 _MENU_ 记录' %}",
        zeroRecords: "{% trans '没找到相应的数据！' %}",
        info: "{% trans '分⻚ _PAGE_ / _PAGES_ 共 _TOTAL_ 条' %}",
        infoEmpty: "{% trans '暂⽆数据！' %}",
        infoFiltered: "{% trans '(从 _MAX_ 条数据中搜索)' %}",
        paginate: {
            first: "{% trans '⾸⻚' %}",
            last: "{% trans '尾⻚' %}",
            previous: "{% trans '上⼀⻚' %}",
            next: "{% trans '下⼀⻚' %}",
        }
    }
    var applicationTable = $('#application').DataTable({
        sProcessing: '<img alt="loadding"src="https://magicbox.bk.tencent.com/static_api/v3/components/loading1/images/loading_2_36x36.gif">',//这⾥很重要，如果你的加载中是⽂字，则直接写上⽂字即可，如果是gif的图⽚，使⽤img标签就可以加载
        pagingType: "full_numbers",
        paging: true, //隐藏分⻚
        ordering: false, //关闭排序
        info: true, //隐藏左下⻆分⻚信息
        searching: false, //关闭搜索
        pageLength: 10, //每⻚显示⼏条数据
        lengthChange: false, //不允许⽤户改变表格每⻚显示的记录数
        language: language, //汉化
        serverSide: true,
        lengthMenu: [5, 10, 25, 50, 75, 100],
        ajax: {
            url: '{{SITE_URL}}get_application_list/',
            method: "get",
            dataType: 'json',
            dataSrc: function (json) {
                json.draw = json.data.info.draw;
                json.recordsTotal = json.data.info.recordsTotal;
                json.recordsFiltered = json.data.info.recordsFiltered;
                json.data = json.data.info.data
                return json.data;
            },
        },
        columnDefs: [
            {
                targets: 0,
                data: "org_name", className: "text-center",
            },
            {
                targets: 1,
                data: "award_name", className: "text-center",
            },
            {
                targets: 2,
                data: "award_status", className: "text-center",
                render: function (data, type, row, meta) {
                    if (data === "⽣效中") {
                        return '<span class="bk-tag is-fill bk-warning">' + data + '</span>';
                    } else {
                        return '<span class="bk-tag is-fill bk-error">'
                            + data + '</span>';
                    }
                }
            },
            {
                targets: 3,
                data: "applicant_info", className: "text-center",
            },
            {
                targets: 4,
                data: "state", className: "text-center",
                render: function (data, type, row, meta) {
                    if (data === "审核中") {
                        return '<span class="bk-tag is-fill bk-gray">' +data + '</span>';
                    } else if (data === "已通过") {
                        return '<span class="bk-tag is-fill bk-primary">' + data + '</span>';
                    } else if (data === "未通过") {
                        return '<span class="bk-tag is-fill bk-error">'
                            + data + '</span>';
                    } else if (data === "未获奖") {
                        return '<span class="bk-tag is-fill bk-light-gray">' + data + '</span>';
                    } else if (data === "已获奖") {
                        return '<span class="bk-tag is-fill bk-success">' + data + '</span>';
                    } else {
                        return '<span class="bk-tag is-fill bk-success">未申报</span > ';
                    }
                }
            },
            {
                targets: 5,
                data: "apply_time", className: "text-center",
            },
            {
                targets: 6,
                data: "apply_id",
                render: function (data, type, row, meta) {
                    if (row.state === "未申报") {
                        return '<a class="bk-icon-button bk-warning bk-button-mini" type="button" onclick="displayAwardModal(' + row.award_id + ')" data-toggle="modal" data-target="#displayModal"title = "申报" >\n' + '<i class="bk-icon icon-file bk-icon"></i >\n' + '<i class="bk-text">申报</i>\n' + '</a>';
                    }
                    else if (row.state === "审核中") {
                        return '<a class="bk-icon-button bk-warning bk-button-mini" type="button" onclick="displayEditAwardModal(' + row.award_id + ',' + data + ')" data-toggle="modal" data-target="#editApplyModal" title="编辑">\n' + '<i class="bk-icon icon-file bk-icon"></i >\n' + '<i class="bk-text">编辑</i>\n' + '</a>';
                    }
                    else if (row.state === "未通过") {
                        return '<a class="bk-icon-button bk-warning bk-button-mini" type="button" onclick="displayEditAwardModal(' + row.award_id + ',' + data + ')" data-toggle="modal" data-target="#editApplyModal" title="编辑">\n' + '<i class="bk-icon icon-file bk-icon"></i >\n' + '<i class="bk-text">编辑</i>\n' + '<a class="bk-icon-button bk-warning bk-button-mini" type="button" onclick="displayAwardModal(' + row.award_id + ')" data-toggle="modal" data-target="#displayModal"title = "重新申请" >\n' + '<i class="bk-icon icon-file bk-icon"></i >\n' + '<i class="bk-text">重新申请</i>\n' + '</a>'
                    }
                    else if (row.state === "已通过") {
                        return '<a class="bk-icon-button bk-warning bk-button-mini" type="button" onclick="displayEditAwardModal(' + row.award_id + ',' + data + ')" data-toggle="modal" data-arget="#editApplyModal" title="编辑">\n' + '<i class="bk-icon icon-file bk-icon"></i >\n' + '<i class="bk-text">编辑</i>\n' + '</a>';
                    }
                    else if (row.state === "已获奖") {
                        return '<a class="bk-icon-button bk-success bk-button-mini" type="button" onclick="displayAwardApplyModal(' + row.award_id + ',' + data + ')" data-toggle="modal" datatarget="#displayEditApplyModal" title="查看">\n' + '<i class="bk-icon icon-search bk-icon"></i >\n' + '<i class="bk-text">查看</i>\n' + '</a>';
                    }
                    else if (row.state === "未获奖") {
                        return '<a class="bk-icon-button bk-success bk-button-mini" type="button" onclick="displayAwardApplyModal(' + row.award_id + ',' + data + ')" data-toggle="modal" datatarget="#displayEditApplyModal" title="查看">\n' + '<i class="bk-icon icon-search bk-icon"></i >\n' + '<i class="bk-text">查看</i>\n' + '</a>';
                    }
                    else {
                        return '<a class="bk-icon-button bk-warning bk-button-mini" type="button" onclick="displayAwardModal(' + row.award_id + ')" data-toggle="modal" data-target="#displayModal"title = "申报" >\n' + '<i class="bk-icon icon-file bk-icon"></i >\n' + '<i class="bk-text">申报</i>\n' + '</a>';
                    }
                }
            },
        ]
    });
</script>
{% endblock %}
